/**
 * @file acommon_err.h
 * @author Morris (morris@mnblog.cn)
 * @brief
 * @version 0.0.1
 * @date 2018-09-26
 *
 * @copyright Copyright (c) 2018
 *
 */
#ifndef __ACOMMON_ERR_H__
#define __ACOMMON_ERR_H__

#include <assert.h>
#include <stdint.h>
#include <stdio.h>

#include "SEGGER_RTT.h"

#ifdef __cplusplus
extern "C"
{
#endif /**< _cplusplus */

  typedef int32_t acommon_err_t;

#define ACOMMON_OK   0
#define ACOMMON_FAIL -1

#ifndef ACOMMON_LOG_TIMESTAMP
#define ACOMMON_LOG_TIMESTAMP 0
#endif

#define ACOMMON_LOGE(format, ...)                                              \
  SEGGER_RTT_printf(0, "E (%d) " format "\r", ACOMMON_LOG_TIMESTAMP,           \
                    ##__VA_ARGS__)
#define ACOMMON_LOGW(format, ...)                                              \
  SEGGER_RTT_printf(0, "W (%d) " format "\r", ACOMMON_LOG_TIMESTAMP,           \
                    ##__VA_ARGS__)
#define ACOMMON_LOGI(format, ...)                                              \
  SEGGER_RTT_printf(0, "I (%d) " format "\r", ACOMMON_LOG_TIMESTAMP,           \
                    ##__VA_ARGS__)
#define ACOMMON_LOGD(format, ...)                                              \
  SEGGER_RTT_printf(0, "D (%d) " format "\r", ACOMMON_LOG_TIMESTAMP,           \
                    ##__VA_ARGS__)
#define ACOMMON_LOGV(format, ...)                                              \
  SEGGER_RTT_printf(0, "V (%d) " format "\r", ACOMMON_LOG_TIMESTAMP,           \
                    ##__VA_ARGS__)

#ifdef __cplusplus
}
#endif /**< _cplusplus */
#endif /**< __ACOMMON_ERR_H__ */
